#include <iostream>
using namespace std;

class Building;

class GoodGay
{
public:
  GoodGay();

  void visit();  // 让visit函数可以访问building中私有成员
  void visit2(); // 让visit2函数不可以访问building中私有成员

  Building *building;
};

class Building
{
  friend void GoodGay::visit();

public:
  Building();

public:
  string m_sittingRoom;

private:
  string m_bedRoom;
};

// 类外实现成员函数
Building::Building()
{
  m_sittingRoom = "客厅";
  m_bedRoom = "卧室";
}

GoodGay::GoodGay()
{
  building = new Building;
}

void GoodGay::visit()
{
  cout << "visit 正在访问：" << building->m_sittingRoom << endl;
  cout << "visit 正在访问：" << building->m_bedRoom << endl;
}

void GoodGay::visit2()
{
  cout << "visit2 正在访问：" << building->m_sittingRoom << endl;
  // cout << "visit 正在访问：" << building->m_bedRoom << endl;
}

void test()
{
  GoodGay gg;
  gg.visit();
  gg.visit2();
}

int main(int argc, char const *argv[])
{
  test();

  return 0;
}